package com.ele.server.util.openntk;

/*import com.ele.model.Answer;
import com.ele.server.util.AnswersGenerator;
import opennlp.tools.cmdline.parser.ParserTool;
import opennlp.tools.parser.Parse;
import opennlp.tools.parser.Parser;
import opennlp.tools.parser.ParserFactory;
import opennlp.tools.parser.ParserModel;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;*/

public class OpenNTKAnswerGenerator/*implements AnswersGenerator*/ {
    /*@Override
    public List<Answer> generate(String question) {
        question.replaceFirst("\\?$", " ?");

        Parser parser = getParser();
        Parse topParse = ParserTool.parseLine(question, parser, 1)[0];
        Parse sqParse = topParse.getChildren()[0];

        generate(topParse);

        String verb;
        String np;
        String adjp;
        for (Parse parse : sqParse.getChildren()) {
            String type = parse.getType();
            if (type.equals("VBZ")) {
                verb = parse.toString();
            } else if (type.equals("NP")) {
                np = parse.toString();
            } else if (type.equals("ADJP")) {
                adjp = parse.toString();
            }
        }



        return null;
    }

    private String generate(Parse parse) {
        Generator generator = null;

        if (parse.getType().equals("SQ")) {
            generator = new SQAnswerGenerator(parse);
        } else {
            generator = new NillGenerator();
        }

        return generator.generate();
    }

    private void sq(Parse[] parses) {
        Parse verb = null;
        Parse np = null;
        Parse adjp = null;

        for (Parse parse : parses) {
            if (parse.getType().equals("VBZ")) {
                verb = parse;
            } else if (parse.getType().equals("NP")) {
                np = parse;
            } else if (parse.getType().equals("ADJP")) {
                adjp = parse;
            }
        }

        if (adjp != null) {

        }
    }

    private Parser getParser() {
        InputStream modelIn = null;
        try {
            modelIn = new FileInputStream("openntk/en-parser-chunking.bin");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        ParserModel model = null;
        try {
            model = new ParserModel(modelIn);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (modelIn != null) {
                try {
                    modelIn.close();
                } catch (IOException e) {
                }
            }
        }

        return ParserFactory.create(model);
    }*/
}
